<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        body {
            height: 3000px;
        }

        .box1 {
            position: relative;
            margin: 100px 200px;
            width: 300px;
            height: 300px;
            background-color: gold;
        }

        .haizi1 {
            width: 100px;
            height: 100px;
            background-color: red;
            position: absolute;
            left: 100px;
            top: 100px;
        }

        .haizi1 div {
            width: 0;
            height: 0;
            border-top: 50px solid green;
            border-bottom: 50px solid blue;
            border-left: 50px solid red;
            border-right: 50px solid black;
        }

        .box2 {
            position: fixed;
            left: 50%;
            top: 50%;
            margin-left: -150px;
            margin-top: -150px;
            width: 300px;
            height: 300px;
            background-color: gold;
        }

        .haizi2 {
            width: 100px;
            height: 100px;
            background-color: red;
            position: relative;
            left: 100px;
            top: 100px;
        }
    </style>
</head>

<body>
    <div class="box1">
        <div class="haizi1">
            <div>
            </div>
        </div>
    </div>
    <div class="box2">
        <div class="haizi2">
        </div>
    </div>

</body>

</html>